package buxfer;

import junit.framework.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import java.util.concurrent.TimeUnit;

/**
 * Created with IntelliJ IDEA.
 * User: stem
 * Date: 18.11.13
 * Time: 19:34
 * To change this template use File | Settings | File Templates.
 */
public class menuPage {
    private  WebDriver driver;
    public  By email = By.xpath("//div[@id='__pageBody']//div[@class='ttMargin']//div[contains(text(),'@')]");
    private By upgr= By.xpath("(//div[@id='__pageBody']//div[@class='ttMargin'])[1]//a[contains(text(),'Upgrade')]");
    private By inv= By.xpath("(//div[@id='__pageBody']//div[@class='ttMargin'])[1]//a[contains(text(),'Invite Friends')]");
    private By help= By.xpath("(//div[@id='__pageBody']//div[@class='ttMargin'])[1]//div[contains(text(),'Help')][@class='drpdwnHandler']");
    private By acnt= By.xpath("(//div[@id='__pageBody']//div[@class='ttMargin'])[1]//div[contains(text(),'Account')][@class='drpdwnHandler']");
    public menuPage(WebDriver driver) {
    this.driver=driver;
        driver.get("https://www.buxfer.com");
    }

    public void mailContain(){
        Assert.assertTrue(driver.findElement(email).isDisplayed());
    }
    public menuUpgrade upgrade(){
        driver.findElement(upgr).click();
        return new menuUpgrade(driver);
    }
    public menuInvite invite(){
        driver.findElement(inv).click();
        return new menuInvite(driver);
    }
  ///////////////////// Два наступних методи це  мега гамнокод, просто робив на швидку руку(copy-paste).
  // Треба звичайно робити як написано в 6 лекції.
    public void help(){
        driver.findElement(help).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        By contact=By.xpath("//div[@class='lAlign']//div[contains(text(),'Contact us')]");
        By faq=By.xpath("//div[@class='lAlign']//div[contains(text(),'FAQs')]");
        By hCenter=By.xpath("//div[@class='lAlign']//div[contains(text(),'Help center')]");
        Assert.assertTrue(driver.findElement(contact).isDisplayed());
        Assert.assertTrue(driver.findElement(faq).isDisplayed());
        Assert.assertTrue(driver.findElement(hCenter).isDisplayed());
    }
    public void account(){
        driver.findElement(acnt).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        By profile=By.xpath("//div[@class='lAlign']//div[contains(text(),'Profile')]");
        By pass=By.xpath("//div[@class='lAlign']//div[contains(text(),'Password')]");
        By memb=By.xpath("//div[@class='lAlign']//div[contains(text(),'Membership')]");
        By alerts=By.xpath("//div[@class='lAlign']//div[contains(text(),'Alerts')]");
        By currency=By.xpath("//div[@class='lAlign']//div[contains(text(),'Currency')]");
        By lang=By.xpath("//div[@class='lAlign']//div[contains(text(),'Language')]");
        By hutr=By.xpath("//div[@class='lAlign']//div[contains(text(),'Help us translate')]");
        By ar=By.xpath("//div[@class='lAlign']//div[contains(text(),'Automatic rules')]");
        By dt=By.xpath("//div[@class='lAlign']//div[contains(text(),'Download transactions')]");
        By logout=By.xpath("//div[@class='lAlign']//div[contains(text(),'Logout')]");
        Assert.assertTrue(driver.findElement(profile).isDisplayed());
        Assert.assertTrue(driver.findElement(pass).isDisplayed());
        Assert.assertTrue(driver.findElement(memb).isDisplayed());
        Assert.assertTrue(driver.findElement(alerts).isDisplayed());
        Assert.assertTrue(driver.findElement(currency).isDisplayed());
        Assert.assertTrue(driver.findElement(lang).isDisplayed());
        Assert.assertTrue(driver.findElement(hutr).isDisplayed());
        Assert.assertTrue(driver.findElement(ar).isDisplayed());
        Assert.assertTrue(driver.findElement(dt).isDisplayed());
        Assert.assertTrue(driver.findElement(logout).isDisplayed());


    }
}